package music_store.ms.common;

import com.google.common.collect.Sets;

import java.util.Set;

public class Const {

    public static final String CURRENT_USER = "currentUser";

    public static final String EMAIL = "email";
    public static final String USERNAME = "username";

    public interface Role{
        int ROLE_VISITOR = 0; //游客
        int ROLE_CUSTOMER = 1; //普通用户
        int ROLE_ADMIN = 2;//管理员
    }

    public interface ProductListOrderBy{
        Set<String> PRICE_ASC_DESC = Sets.newHashSet("price_asc","price_desc");
    }

    public interface Cart{
        Integer CHECKED = 1; //购物车为选中状态
        Integer UN_CHECKED = 0; //购物车为未选中状态
    }

    public enum ProductStatusEnum{
        ON_SALE(1,"在售"),
        INVALID(2,"无版权");

        private Integer code;
        private String value;
        ProductStatusEnum(int code,String value){
            this.code = code;
            this.value = value;
        }

        public int getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }
    }

    public enum OrderStatusEnum{
        CANCELED("已取消", 0),
        NO_PAY("未支付",10),
        PAID("已支付",20),
        ORDER_SUCCESS("订单完成",30),
        ORDER_CLOSED("订单关闭",40);

        private String value;
        private int code;

        OrderStatusEnum(String value,int code){
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static OrderStatusEnum codeOf(int code){
            for (OrderStatusEnum orderStatusEnum : values()){
                if (orderStatusEnum.getCode() == code){
                    return orderStatusEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举。");
        }
    }

    public interface alipayCallBack{
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILED = "failed";
    }

    public enum payPlatformEnum{

        ALIPAY("支付宝",1);

        private String value;
        private int code;

        payPlatformEnum(String value,int code){
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }
    }

    public enum PaymentTypeEnum{

        ONLINE_PAY("在线支付",1);

        private String value;
        private int code;

        PaymentTypeEnum(String value,int code){
            this.value = value;
            this.code = code;
        }

        public String getValue() {
            return value;
        }

        public int getCode() {
            return code;
        }

        public static PaymentTypeEnum codeOf(int code){
            for (PaymentTypeEnum paymentTypeEnum : PaymentTypeEnum.values()){
                if (paymentTypeEnum.getCode() == code){
                    return paymentTypeEnum;
                }
            }
            throw new RuntimeException("没有找到对应的枚举。");
        }
    }





}
